/*
 * @Description: 
 * @Author: paddies
 * @Date: 2023-05-26 22:34:22
 * @LastEditors: paddies
 * @LastEditTime: 2023-11-17 23:50:56
 * @FilePath: /luntai-user-app/lib/components/build-icon/buildIcon.dart
 */
import 'package:flutter/widgets.dart';

Widget buildIcon({
  String url = "",
  double width = double.infinity,
  double height = double.infinity,
  BoxFit fit = BoxFit.cover,
}) {
  if (url.startsWith("assets/")) {
    url = url;
  } else {
    url = "assets/images/icon/$url";
  }

  return Container(
      height: height,
      width: width,
      child: ClipRect(
        child: Image.asset(
          url,
          height: height,
          width: width,
          fit: fit,
        ),
      ));
}

Widget buildAwardIcon({
  String url = "",
  double width = double.infinity,
  double height = double.infinity,
  BoxFit fit = BoxFit.cover,
}) {
  return SizedBox(
      height: height,
      width: width,
      child: ClipRect(
        child: Image.asset(
          "assets/images/award/$url",
          height: height,
          width: width,
          fit: fit,
        ),
      ));
}

class SizeConfig {
  static MediaQueryData? _mediaQueryData;

  static double? screenWidth;

  static double? screenHeight;

  static double? blockSizeHorizontal;

  static double? blockSizeVertical;

  static double? _safeAreaHorizontal;

  static double? _safeAreaVertical;

  static double? safeBlockHorizontal;

  static double? safeBlockVertical;

  void init(BuildContext context) {
    _mediaQueryData = MediaQuery.of(context);

    screenWidth = _mediaQueryData!.size.width;

    screenHeight = _mediaQueryData!.size.height;

    blockSizeHorizontal = screenWidth! / 100;

    blockSizeVertical = screenHeight! / 100;

    _safeAreaHorizontal =
        _mediaQueryData!.padding.left + _mediaQueryData!.padding.right;

    _safeAreaVertical =
        _mediaQueryData!.padding.top + _mediaQueryData!.padding.bottom;

    safeBlockHorizontal = (screenWidth! - _safeAreaHorizontal!) / 100;

    safeBlockVertical = (screenHeight! - _safeAreaVertical!) / 100;
  }
}
